//
//  ChongZhiController.m
//  夺宝吧
//
//  Created by xiaocai on 15/11/27.
//  Copyright © 2015年 FangYuan. All rights reserved.
//

#import "ChongZhiController.h"

#import "ZhifuCell1.h"
#import "ZhiFuCell2.h"
#import "ZhiFuCell3.h"
//#import "ZhiFuModel.h"
#import "PayedVC.h"
#import "Iapppay.h"
#import "JDWebPayVC.h"
#import "UIButton+WebCache.h"

@interface ChongZhiController () <UITableViewDataSource, UITableViewDelegate,ZhifuCell1Delegate>

@property (nonatomic , strong) NSMutableArray *cellDatas;

@property (nonatomic , strong) NSAttributedString *duobaobiStr;
@property (nonatomic , strong) NSAttributedString *jifenStr;

@end

@implementation ChongZhiController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.ordermodel = [[orderModel alloc]init];
    self.ordermodel.money = @"50";
    
//    self ZhifuCell1:nil button:
//    self.duobaobiStr = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:sender.titleLabel.text RightStr:@"" Font:13];
//    
//    self.jifenStr = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[sender.titleLabel.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:13];
    
    self.cellDatas = [NSMutableArray array];
    
    // Do any additional setup after loading the view from its nib.
    self.cusTableView.delegate = self;
    self.cusTableView.dataSource = self;
    
    //注册tableView的cell
    [self.cusTableView registerNib:[UINib nibWithNibName:@"ZhifuCell1" bundle:nil] forCellReuseIdentifier:@"cell1"];
    [self.cusTableView registerNib:[UINib nibWithNibName:@"ZhiFuCell2" bundle:nil] forCellReuseIdentifier:@"cell2"];
    [self.cusTableView registerNib:[UINib nibWithNibName:@"ZhiFuCell3" bundle:nil] forCellReuseIdentifier:@"cell3"];
    
    [self setUpHeaderView];
    [self setData];

}

//设置headerView
- (void)setUpHeaderView{
    self.headerView.backgroundColor =  [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"icon_login_topbar_all.png"]];
//    self.headerView.contentMode = UIViewContentModeScaleAspectFit;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    [self.headerView sendSubviewToBack:self.backImage];
//    self.cusTableView.tableHeaderView = nil;
    self.cusTableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.cusTableView.bounds.size.width, 0.01f)];
    
    [self updateUserInfo];
    
}
//更新用户基本数据
- (void)updateUserInfo{
    self.touxiangButton.layer.cornerRadius = CGRectGetWidth(self.touxiangButton.frame) / 2.0;
    self.touxiangButton.clipsToBounds = YES;
    self.touxiangButton.layer.borderColor = [UIColor whiteColor].CGColor;
    self.touxiangButton.layer.borderWidth = 1.0f;
    UserInfo *user = [[UserInfo alloc]init];
//    [self.touxiangButton sd_setImageWithURL:[NSURL URLWithString:user.user_header_img_path] placeholderImage:[UIImage imageNamed:@"iphone_5"]];
   [self.touxiangButton sd_setImageWithURL:[NSURL URLWithString:user.user_header_img_path] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"iphone_5"]];

    self.userNameLabel.text = user.user_name;
    if (user.user_money != nil) {
        self.duobiLabel.text = [NSString stringWithFormat:@"夺币:%@",user.user_money];
    }else{
        self.duobiLabel.text = @"夺币:0";
    }
    if (user.user_jifen != nil) {
        self.jifenLabel.text = [NSString stringWithFormat:@"积分:%@",user.user_jifen];
    }else{
        self.jifenLabel.text = @"积分:0";
    }
}
//设置数据源
- (void)setData{
    //生成模型
    ZhiFuModel *model1 = [[ZhiFuModel alloc]init];
    model1.imageStr = @"icon_alipay_z.png";
    model1.cusLabelStr = @"支付宝";
    model1.detailStr = @"推荐拥有支付宝的用户使用";
    model1.isSelected = NO;
    model1.option = ZhiFuModelZhiFuBao;
    model1.cusLabelColor = QBB_RED_COLOR;
    
    ZhiFuModel *model2 = [[ZhiFuModel alloc]init];
    model2.imageStr = @"icon_jingdong.png";
    model2.cusLabelStr = @"京东网银";
    model2.detailStr = @"支持银联储蓄卡、信用卡支付";
    model2.isSelected = NO;
    model2.option = ZhiFuModelJingDong;
    
    ZhiFuModel *model3 = [[ZhiFuModel alloc]init];
    model3.imageStr = @"icon_weixinpay.png";
    model3.cusLabelStr = @"微信支付";
    model3.detailStr = @"推荐已开通微信钱包的用户使用";
    model3.isSelected = NO;
    model3.option = ZhiFuModelWeiXinIappay;
    
    ZhiFuModel *model4 = [[ZhiFuModel alloc]init];
    model4.imageStr = @"icon_alipay_z.png";
    model4.cusLabelStr = @"支付宝";
    model4.detailStr = @"使用爱贝收银台的支付宝支付";
    model4.isSelected = NO;
    model4.option = ZhiFuModelZhiFuBaoIappay;
    model4.cusLabelColor = QBB_RED_COLOR;
    
    //确定那个是默认选择的
    if (self.is_alipay_mobile){
        model1.isSelected = YES;
    }
    else{
        if (self.is_iapppay_zfb){
            model4.isSelected = YES;
        }
        else
        {
            if (self.is_pingpp_jd){
                model2.isSelected = YES;
            }
            
            else{
                if (self.is_iapppay_wx)
                {
                    model3.isSelected = YES;
                }
            }
        }
    }
    
    //将生成的模型添加到数据源中
    if(self.is_alipay_mobile){
        [self.cellDatas addObject:model1];
    }
    if (self.is_iapppay_zfb){
        [self.cellDatas addObject:model4];
    }
    
    if (self.is_pingpp_jd){
        [self.cellDatas addObject:model2];
    }
    if (self.is_iapppay_wx){
        [self.cellDatas addObject:model3];
    }
//    self.cellDatas = @[model1,model2,model3,model4];
//    cell3.duobiLabel.attributedText = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:sender.titleLabel.text RightStr:@"" Font:14];
//    cell3.jifenLabel.attributedText = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[sender.titleLabel.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:14];
    self.duobaobiStr = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:@"50" RightStr:@"" Font:13];
    self.jifenStr = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:50]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:13];
}

//设置tableView的footerView
-(void)setFooterView{
    
    self.cusTableView.tableFooterView = [[[NSBundle mainBundle]loadNibNamed:@"ZhiFuCell3" owner:nil options:nil] lastObject];
    

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - tableView 数据源方法


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0){
        return 1;
    }
    if (section == 1){
        return self.cellDatas.count;
    }
    if (section == 2){
        return 1;
    }
    return 0;
}
//cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0){
        return 91.0;
    }
    
    if (indexPath.section == 1){
        return 50.0;
    }
    if (indexPath.section == 2){
        return 62.0;
    }
    
    return 0.0;
}
//header的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 20.0;
}
//footer的高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 1.0;
}

//生成cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section == 0){
        ZhifuCell1 *cell1 =  [tableView dequeueReusableCellWithIdentifier:@"cell1" forIndexPath:indexPath];
        cell1.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell1.delegate = self;
        
        return cell1;
    }
    
    if (indexPath.section == 1){
        ZhiFuCell2 *cell2 = [tableView dequeueReusableCellWithIdentifier:@"cell2" forIndexPath:indexPath];
//        cell2.selectionStyle = UITableViewCellSelectionStyleNone;
        
        ZhiFuModel *model = self.cellDatas[indexPath.row];
        [cell2 configureWithModel:model];
        return cell2;
    }
    
    if (indexPath.section == 2){
        ZhiFuCell3 *cell3 =  [tableView dequeueReusableCellWithIdentifier:@"cell3" forIndexPath:indexPath];
        cell3.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell3.duobiLabel.attributedText = self.duobaobiStr;
        cell3.jifenLabel.attributedText = self.jifenStr;
        return cell3;
    }
    return nil;
    
}

//groupHeaderView
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIColor *backColor = tableView.backgroundColor;
    if (section == 0){
        
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = backColor;
        
        UILabel *label = [[UILabel alloc]init];
        label.frame = CGRectMake(10, 0, WYMWITH, 20);
        label.font= [UIFont systemFontOfSize:12.0];
        label.text = @"1.选择充值的金额";
        [view addSubview:label];
        return view;
    }
    
    if (section == 1){
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = backColor;
        
        UILabel *label = [[UILabel alloc]init];
        label.frame = CGRectMake(10, 0, WYMWITH, 20);
        label.font= [UIFont systemFontOfSize:12.0];
        label.text = @"2.选择支付方式";
        [view addSubview:label];
        return view;

    }
    if (section == 2){
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = backColor;
        
        UILabel *label = [[UILabel alloc]init];
        label.frame = CGRectMake(10, 1, WYMWITH, 20);
        label.font= [UIFont systemFontOfSize:12.0];
        label.text = @"3.充值所得";
        [view addSubview:label];
        return view;
    }
    
    return nil;
}
//groupFooterView
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
//    if (section == 1){
//        UIView *view = [[UIView alloc]init];
//        view.backgroundColor = [UIColor clearColor];
//        return view;
//    }
    UIView *view = [[UIView alloc]init];
    view.backgroundColor = tableView.backgroundColor;
    return view;
}
#pragma mark - tableview代理方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0){
        [tableView deselectRowAtIndexPath:indexPath animated:NO];
    }
    //选择支付类型
    if (indexPath.section == 1){
        
        for (ZhiFuModel *model in self.cellDatas){
            model.isSelected = NO;
        }
        ZhiFuModel *model = self.cellDatas[indexPath.row];
        model.isSelected = YES;
        
        [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
        
    }
}


//返回按钮的点击事件
- (IBAction)backBtnClick:(UIButton *)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}
//点击头像的响应事件
- (IBAction)touxiangBtnClick:(UIButton *)sender {
    
    
}
//提交支付按钮
- (IBAction)tijiaoBtnClick:(UIButton *)sender {
    
    
    
    //此时ordermodel中的钱的数量已经填好
    if ([self.ordermodel.money integerValue] < 1 || [self.ordermodel.money integerValue] > CHONGZHI_LIMIT ){
        
        
        [WYPublic showErrorWithTitle:nil Msg:@"充值金额必须为大于1小于1000的整数"];
        return;
    }
    for (ZhiFuModel *model in self.cellDatas){
        if (model.isSelected){
            switch (model.option) {
                case ZhiFuModelZhiFuBao:{
                    self.ordermodel.pay_type = @"alipay_mobile";
                    self.ordermodel.option = ZhiFuModelZhiFuBao;
                    self.ordermodel.payModel = self.zfbModel;
                    
                }
                    break;
                case ZhiFuModelJingDong:{
                    self.ordermodel.pay_type = @"jdpay_mobile";
                    self.ordermodel.option = ZhiFuModelJingDong;
                    self.ordermodel.payModel = self.pingppJDModel;

                }
                    break;
                    //
                case ZhiFuModelWeiXinIappay:{
                    self.ordermodel.pay_type = @"iapppay";
                    self.ordermodel.option = ZhiFuModelWeiXinIappay;
                    self.ordermodel.payModel = self.iapppayWXModel;

                }
                    break;
                    //爱贝支付宝
                case ZhiFuModelZhiFuBaoIappay:{
                    self.ordermodel.pay_type = @"iapppay";
                    self.ordermodel.option = ZhiFuModelZhiFuBaoIappay;
                    self.ordermodel.payModel = self.iapppayzfbModel;

                }
                    break;
                    
                default:
                    break;
            }
        }
    }
    if (self.ordermodel.payModel == nil){
        [WYPublic showErrorWithTitle:@"" Msg:@"你没有选择支付方式"];
        return;
    }
    
    
    [self generateOrder];
}
#pragma mark -- 生成订单
- (void)generateOrder{
    [WYPublic addHudToWindow];
    //先生成订单
    NSDictionary *pararms = @{@"money":self.ordermodel.money,@"uid":[UserInfo getUserID],@"token":[UserInfo getUserToken],@"refresh_token":[UserInfo getRefreshToken]};

    NSString *url = [NSString stringWithFormat:@"%@%@",DBB_IP,MAKEORDER_URL];
    [WYRequest startPostForDicWithUrlStR:url Parameters:pararms successBlock:^(NSDictionary *dic) {
        [WYPublic removeHudToWindow];
        NSNumber *ret = dic[@"ret"];
        
        if (ret.intValue == 0){
            self.ordermodel.order_id = dic[@"data"][@"pay_order"][@"id"];
            self.ordermodel.pay_code = dic[@"data"][@"pay_order"][@"pay_code"];
            
            [self payYanzheng];
        }
        else{
            return ;
        }
        
       
    } failedBlock:^{
        [WYPublic removeHudToWindow];
        
    } needLog:NO];
}

//支付前验证
- (void)payYanzheng{
    
    //京东网页支付不用验证
    if (self.ordermodel.option == ZhiFuModelJingDong){
        //京东网页支付不需要验证
        [self startPayWithJingDong];
        return;
    }
    
    //支付宝原生
 NSDictionary *params = @{@"id":self.ordermodel.order_id,@"pay_type":self.ordermodel.pay_type,@"uid":[UserInfo getUserID],@"token":[UserInfo getUserToken],@"refresh_token":[UserInfo getRefreshToken]};
    //爱贝微信
    if (self.ordermodel.option == ZhiFuModelWeiXinIappay){
         params = @{@"id":self.ordermodel.order_id,
                                  @"pay_type":self.ordermodel.pay_type,
                                  @"uid":[UserInfo getUserID],
                                  @"token":[UserInfo getUserToken],
                                  @"refresh_token":[UserInfo getRefreshToken]};
    }
    //爱贝支付宝
    if (self.ordermodel.option == ZhiFuModelZhiFuBaoIappay){
        params = @{@"id":self.ordermodel.order_id,
                   @"pay_type":self.ordermodel.pay_type,
                   @"uid":[UserInfo getUserID],
                   @"token":[UserInfo getUserToken],
                   @"refresh_token":[UserInfo getRefreshToken]};
    }
   
    NSString *url = [NSString stringWithFormat:@"%@%@",DBB_IP,YANZHENG_URL];
    [WYRequest startPostForDicWithUrlStR:url Parameters:params successBlock:^(NSDictionary *dic) {
        
        NSString *ret = dic[@"ret"];
        if (ret.intValue == 0){
            if (self.ordermodel.option == ZhiFuModelZhiFuBao || self.ordermodel.option == ZhiFuModelWeiXinIappay){
                //支付宝 和 爱贝微信支付需要验证
                [self startPayWithzfbAndIapppayWX];
            }
            //爱贝支付宝
            if (self.ordermodel.option == ZhiFuModelZhiFuBaoIappay){
                [self startPayWithIapppayZhiFuBao];
            }
        }
        else{
            [WYPublic showMessageWithTitle:@"" Msg:dic[@"msg"]];
        }

        //支付宝 和 爱贝微信支付
        

        
    } failedBlock:^{
        
        
        
    } needLog:NO];
    

}

//支付宝支付 爱贝微信支付
#pragma mark -- 验证完成后开始支付
- (void)startPayWithzfbAndIapppayWX{
    
    NSDictionary *params = @{@"id":self.ordermodel.order_id,@"pay_type":self.ordermodel.pay_type,@"uid":[UserInfo getUserID],@"token":[UserInfo getUserToken],@"refresh_token":[UserInfo getRefreshToken]};
    NSString *url = [NSString stringWithFormat:@"%@%@",DBB_IP,YANZHENG_URL];
    [WYRequest startPostForDicWithUrlStR:url Parameters:params successBlock:^(NSDictionary *dic) {
        NSNumber *ret  = dic[@"ret"];
        if (ret.intValue == 0){
            //支付宝
            if (self.ordermodel.option == ZhiFuModelZhiFuBao){
                WYZfbPay *zfbPay = [[WYZfbPay alloc]init];
                //传入支付模型
                zfbPay.payModel = self.ordermodel.payModel;
                zfbPay.isChongZhiFlag = YES;
                [zfbPay zfbPayWithOrderNum:self.ordermodel.pay_code OrderId:self.ordermodel.order_id PdcTitle:self.ordermodel.payModel.recharge_name PdcDesc:[NSString stringWithFormat:@"夺宝吧支付_iOS_%@",self.ordermodel.pay_code] Price:[NSString stringWithFormat:@"%@",self.ordermodel.money] ];
                //跳往支付结果界面
                //[self.navigationController popViewControllerAnimated:YES];
                PayedVC *payedVC = [[PayedVC alloc]init];
                payedVC.money = [NSString stringWithFormat:@"%@",self.ordermodel.money];
                payedVC.isChongZhiFlag = YES;
                [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:payedVC animated:YES];

            }
            //爱贝微信
            if (self.ordermodel.option == ZhiFuModelWeiXinIappay){
                
                Iapppay *iappay = [[Iapppay alloc] initWithPayModel:self.ordermodel.payModel];
                //传入支付模型
                iappay.payModel = self.ordermodel.payModel;
                iappay.isChongZhiFlag = YES;
                [iappay iappayWithOrderId:self.ordermodel.pay_code price:[NSString stringWithFormat:@"%@",self.ordermodel.money] privateInfo:[NSString stringWithFormat:@"夺宝吧支付_iOS_%@",self.ordermodel.pay_code] wareName:self.ordermodel.payModel.recharge_name];
                
                //跳往支付结果界面
                //[self.navigationController popViewControllerAnimated:YES];
                PayedVC *payedVC = [[PayedVC alloc]init];
                payedVC.money = [NSString stringWithFormat:@"%@",self.ordermodel.money];
                payedVC.isChongZhiFlag = YES;
                [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:payedVC animated:YES];
                
            }
        }
        
    } failedBlock:^{
        NSLog(@"%@",@"failedBlock");
        
    } needLog:NO ];
}


//京东支付
#pragma mark -- 京东支付
- (void)startPayWithJingDong{
    
    JDWebPayVC *jdvc = [[JDWebPayVC alloc]init];
    jdvc.mtitle = @"支付页面";
    jdvc.isChongZhiFlag = YES;
    jdvc.money = [NSString stringWithFormat:@"%@",self.ordermodel.money];
    jdvc.urlStr = [NSString stringWithFormat:@"%@api/ApiPay/pay?uid=%@&token=%@&id=%@&pay_type=pingpp&sub_pay_type=jdpay_wap",DBB_IP,[UserInfo getUserID],[UserInfo getUserToken],self.ordermodel.order_id];
    [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:jdvc animated:YES];
    
}

//爱贝支付宝支付
- (void)startPayWithIapppayZhiFuBao{
    Iapppay *iappay = [[Iapppay alloc] initWithPayModel:self.ordermodel.payModel];
    iappay.isChongZhiFlag = YES;
    [iappay iappayWithOrderId:self.ordermodel.pay_code price:[NSString stringWithFormat:@"%@",self.ordermodel.money] privateInfo:[NSString stringWithFormat:@"夺宝吧支付_iOS_%@",self.ordermodel.pay_code] wareName:self.ordermodel.payModel.recharge_name];
    
    //跳往支付结果界面
    //[self.navigationController popViewControllerAnimated:YES];
    PayedVC *payedVC = [[PayedVC alloc]init];
    payedVC.money = [NSString stringWithFormat:@"%@",self.ordermodel.money];
    payedVC.isChongZhiFlag = YES;
    [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:payedVC animated:YES];
}

#pragma mark - 支付cell1的代理

- (void)ZhifuCell1:(ZhifuCell1 *)cell button:(UIButton *)sender{
    
//   ZhiFuCell3 *cell3 =  [self.cusTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
//   ZhiFuCell3 *cell3  =  [self.cusTableView dequeueReusableCellWithIdentifier:@"cell3" forIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
    
    self.duobaobiStr = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:sender.titleLabel.text RightStr:@"" Font:13];
    self.jifenStr = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[sender.titleLabel.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:13];
    
    NSLog(@"button text:%@",sender.titleLabel.text);
    self.ordermodel.money = sender.titleLabel.text;
    
    [self.cusTableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationNone];
    
    [self.cusTableView reloadData];
}
//换算积分
-(NSInteger)getJiFen:(NSInteger)money
{
//    ZhiFuCell3 *cell3 =  [self.cusTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
//    ZhiFuCell3 *cell3  =  [self.cusTableView dequeueReusableCellWithIdentifier:@"cell3" forIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
    NSInteger rlt = 0;
    NSArray *jifens = self.peizhiDic[@"consume_score_config"];
    for (NSDictionary *jifen in jifens) {
        NSNumber *min = jifen[@"gte"];
        NSNumber *max = jifen[@"lte"];
        NSNumber *bili = jifen[@"percent"];
        if (money >= min.integerValue && money <= max.integerValue) {
            rlt = money*bili.floatValue;
        }
    }
//    if (rlt <= 0) {
//        //隐藏积分lab
//        
//        cell3.jifenLabel.hidden = YES;
//    }else {
//        cell3.jifenLabel.hidden = NO;
//        
//    }
    return rlt;
}

- (void)ZhifuCell1:(ZhifuCell1 *)cell otherMoneyFieldResignFirstResponder:(UITextField *)textField{
    NSLog(@"textField text:%@",textField.text);
    
    
//    ZhiFuCell3 *cell3 =  [self.cusTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
    
    self.duobaobiStr = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:textField.text RightStr:@"" Font:14];
    self.jifenStr = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[textField.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:14];
    
    self.ordermodel.money = textField.text;
    
    
    [self.cusTableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationNone];
}

@end
